package com.jinlejia.erp.ui.mine.contract

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import com.jinlejia.erp.R
import com.jinlejia.erp.databinding.ActivityMyRecordingBinding

/**
 * 我的录音
 * */
class MyRecordingActivity : AppCompatActivity() {
    private val binding by lazy {
        DataBindingUtil.setContentView<ActivityMyRecordingBinding>(
            this,
            R.layout.activity_my_recording
        )
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding.btBack.setOnClickListener { finish() }
        switchSegment(0)
        binding.segmentControl.setOnSegmentControlClickListener {
            switchSegment(it)
        }

    }

    private fun switchSegment(i: Int) {
        val sfm = supportFragmentManager.beginTransaction()
        if (i == 0) {
            sfm.replace(binding.content.id, SaleRecordingFragment().newInstance("shsbasic"))
        } else if (i == 1) {
            sfm.replace(binding.content.id, SaleRecordingFragment().newInstance("rentbasic"))
        }
        sfm.commitAllowingStateLoss()
    }

}
